import com.gitee.chessboard.jdbc.JdbcManager;
import com.gitee.chessboard.manager.DefaultDictionaryManager;
import com.gitee.chessboard.parser.DefaultConstantDictionaryParser;
import com.gitee.chessboard.parser.DefaultEnumDictionaryParser;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 * 测试创建表功能
 *
 * @author 敲代码的旺财
 * @date 2021/11/23 15:45
 */
public class CreateTableTest {

    public static void main(String[] args) {
        SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
        SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(CreateTableTest.class.getClassLoader().getResourceAsStream("mybatis.xml"));
        Configuration configuration = sqlSessionFactory.getConfiguration();
        PooledDataSource dataSource = (PooledDataSource) configuration.getEnvironment().getDataSource();
        JdbcManager jdbcManager = new JdbcManager(
                dataSource.getDriver()
                , dataSource.getUrl()
                , dataSource.getUsername()
                , dataSource.getPassword());
        jdbcManager.setMybatisSqlSessionFactory(sqlSessionFactory);
        DefaultDictionaryManager manager = new DefaultDictionaryManager(jdbcManager);
        manager.setEnumDictionaryParser(new DefaultEnumDictionaryParser(manager));
        manager.setConstantDictionaryParser(new DefaultConstantDictionaryParser(manager));
        manager.init();
    }


}
